package com.learn.swagger.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * web配置
 *
 * spring boot 2.0以后 WebMvcConfigurerAdapter 这个方法已经过时
 * 继承WebMvcConfigurationSupport这个类，会导致自动配置失效
 * 应该直接实现WebMvcConfigurer这个接口
 *
 * @author zhousiqi
 * @version 1.0.0
 * @date 2019/2/26 14:29
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 配置swagger的静态资源路径
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}
